import { HttpExceptionFilter } from '@app/common/filters/httpexception/httpexception.filter';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

const normalizePort = (val: any) => {
  const port = parseInt(val, 10);
  if (isNaN(port)) {
    return val;
  }
  if (port >= 0) {
    return port;
  }
  return false;
};
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const port = normalizePort(process.env.PORT || '3000');
  app.enableCors({
    origin: '*',
  });
  app.useGlobalFilters(new HttpExceptionFilter());
  await app.listen(port);
  console.log(`Application is running at ${await app.getUrl()}`);
}
bootstrap();
